﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChongJu.ModelManager.Rating
{
    public class AccountModel
    {
        public string AccountID { get; set; }

        public string FarmerName { get; set; }

        public string IDCard { get; set; }

        public int BatchNo { get; set; }

        public string DeviceID { get; set; }

        public DateTime CreateTime { get; set; }

        public DateTime EndTime { get; set; }

        public AccountEnum Status
        {
            get
            {
                if (Levels.Exists(q => q.Weights.Exists(f => f.WeightStatus == AccountEnum.Create)) == true)
                    return AccountEnum.Create;
                else if (Levels.Exists(q => q.Weights.Exists(f => f.WeightStatus == AccountEnum.Sure)) == true)
                    return AccountEnum.Sure;
                else
                    return AccountEnum.Submit;
            }
        }

        public List<AccountLevelModel> Levels { get; set; } = new List<AccountLevelModel>();

        public AccountModel Clone()
        {
            var model = this.MemberwiseClone() as AccountModel;
            model.Levels = this.Levels.Select(q => q.Clone()).ToList();
            return model;
        }
    }


}
